﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace WcfFlashRemoting.Example6.Implementation
{
    [ServiceBehavior(Namespace = "urn:WcfFlashRemoting:Examples:Example6")]
    class CalculatorService : Contract.ICalculatorContract
    {
        #region ICalculatorContract Members

        public Contract.MathResult Add(Contract.MathParameters parameters)
        {
            if (parameters.Authentication == null || parameters.Authentication.User != "good")
            {
                throw new FaultException<Contract.NotAuthorizedFault>(new Contract.NotAuthorizedFault(), new FaultReason("The User provided did not have permission to use this operation."));
            }
            return new Contract.MathResult()
            {
                Result = parameters.a + parameters.b
            };
        }

        #endregion
    }
}
